GSP-004 Creating a Persistent Disk (Activity Tracking)

2017 10 18일 수요일

오전 9:29

링크: https://qwiklabs.com/focuses/6985

 

The only difference between both the labs is the Activity Tracking which is present in Creating a Persistent Disk (Activity Tracking) lab. 

Activity Tracking is depended on a scoring algorithm on which a user can track their activity logs. The scoring algorithm is completely based on lab steps, if a user failed in any step or missed it by mistake it may cause that the particular objective to failed. So, a user needs to perform these labs carefully to score 100%. 

 

Hope this address your concern. Feel free to ask if you have any other questions.

 

Best Regards, 

Jyotiranjan Seth

 

오버뷰

Google Compute Engine 으로 VM 을 만들 수 있다

- Linux로는 Debian, Ubuntu, Suse, Red Hat, CoreOs

- Windows Server 도 가능

 

Google Compute Engine 에는 VM 인스턴스를 담을 저장공간으로  persistent storage를 제공한다.

- 하드디스크랑 같다고 생각하자

- VM delete 해도, VM에 붙어있던 persistent storage와 저장되어 있던 data는 살아있고

심지어는 다른 VM attach 할 수도 있다.

- Standard SSD 두 종류가 있다.

 

랩에서

1) VM 인스턴스 만들고 Persistent disk를 붙이자

2) Persistent disk Format 하고 Mount 하자

 

 

새로운 VM 인스턴스를 생성해보자

 

사전 작업

 

Google Cloud Platform 
Manage resources 
Filter by name, ID, project number, or label 
CREATE PROJECT 
Columns 
Select a resource 
Welcome Co Cloud Shell ! Type "help" to get started. 
google106724 studentecloudshell: —$ gcloud auth list 
Credentialed Account s 
ACTIT.TE xccoUNT 
. net 
To set the active account, run : 
$ gcloud config set account 
google106724 gcloud list project 
[core] 
project (unset) 
Your active is: [cloudsheII—16084 
google106724 gcloud set project 
Updated property [core/ proj . 
google106724 gcloud config list project 
project = 
Your active is: [cloudsheII—16084] 
google106724 —

 

1. gcloud auth list

- 현재 가능한 계정 확인

 

2. gcloud config list project

- proejct list

 

3. gcloud config set project <project id>

- core section project set

 

 

구글 클라우드 쉘로 만들어보자

 

- 명령어는

- gcloud compute instances create gcelab --zone us-central1-c

- 결과로

- 10기가 persistent storage가 붙은 VM 인스턴스가 만들어짐

- Internal/External IP가 할당되고

- 머신타입은 n1-standard-1, 존은 us-central1-c

- 이름은 gcelab

google106724 gcloud convute instances create gcelab —zone us—central 
Created [https://www.googIeapis.cæ/conpute/vI/projects/qwikIabs—gcp—eOe68b8S7ab09279/zones/us—centraII—c/in3tances/gceIab] . 
gcelab us—central 
BACHINE TYPE PREEMPTIBLE INTERNAL 1 P 
10.128.0.2 
EXTERNAL IP 
107 .178.213. Iss RUNNING 
google106724 —$

 

- 웹콘솔에서도 확인가능

VM instances 
Filter VM instances 
Q 
Compute Engine 
VM instances 
Instance groups 
Instance templates 
Disks 
CREATE INSTANCE 
Recommendation 
IMPORT VM 
C REFRESH 
Connect 
Name A 
e gcelab 
Zone 
us-centrall-c 
Internal IP 
ID 128.02 
External IP

 

궁금증. project를 설정 안하고 했다면 어떻게 되었을까?

 

Create a new persistent disk

 

VM과 같은 zone persistent disk를 만들자

- 이름은 mydisk

- 사이즈는 200GB

- zone us-central1-c

 

* 사용하려면 format mount 가 필요하다고 안내된다

google106724 gcloud convute disks create mydisk —size=200GB —zone 
Created [https://www.googIeapis.cæ/conpute/vI/projects/qwikIabs—gcp—eOe68b8S7ab09279/zones/us—centraII—c/disks/m-Äisk] . 
SIZE TYPE 
mydisk us—central 200 
pd—standard READY 
New disks are unfomatted. You must fomat and mount a disk before it 
can be used. You can find instructions on how Co do this at: 
https : / / cloud . google . cow' di s ks/add—ger si stent—di s k*formatting

 

Attach a disk

 

만든 Persistent disk gcelab 이라는 이름으로 만들어둔 VM 붙여보자

 

google106724 gcloud convute instances gcelab —disk mydisk —zone 
Updated [https://www.googIeapis.cæ/conpute/vI/projects/qwikIabs—gcp—eOe68b8S7ab09279/zones/us—centraII—c/in3tances/gceIab] .

 

웹콘솔을 통해서도 attach 것을 있다.

 

* VM 인스턴스를 지워도 DISK는 유지된다!

Boot disk and local disks 
Name 
gcelab 
[S' Oe'ete boot disk when instance is deleted 
Additional disks 
Name 
mydisk 
size (GB) 
size (GB) 
200 
Type 
Standard persistent disk 
Type 
Standard persistent disk 
Mode 
Boot, read/write 
Mode 
Read/write 
When deleting instance 
Keep disk

 

e myd'sk 
Type 
Standard persistent disk 
200 
Zone 
us-central I-c 
In use by 
gcelab 
Estimated performance 
Operation Type 
Sustained random IOPS limit 
Sustained throughput limit (MB's) 
Encryption 
Automatic 
Equivalent REST 
Read 
150.00 
2410 
Wri te 
2410

 

Finding the persistent disk in the virtual machine

 

1. 우리는 현재 Google Cloud Shell 을 돌리는 VM에 있다.

2. SSH gcelab 이라는 VM 으로 접속해보자

google106724 
WARNING: The 
WARNING: The 
WARNING: You 
WARNING: ssH 
lgcloud ssh gcelab — 
public SSH key file for gcloud does not exist. 
private SSH key file for gcloud does not exist. 
do not have an SSH key for gcloud. 
keygen will be executed to generate a key. 
—zone 
This tool needs to create the directory 
[/hcme/googIe106724 student/ .ssh] before being able to generate SSH 
keys . 
Do you want to continue (Y/n)? 
Generating public/private rsa key pair . 
Enter passphrase (empty for no passphrase) : 
Enter passphrase again: 
Your identification has been saved in /home/googIe106724 student/ .ssh/google cmpute engine. 
Your public key has been saved in / home/ google106724 student/ .ssh/google compute engine. pub. 
The key fingerprint is: 
google106724 student@cs-6000-devshe11-vm-19Sb723f-8b60-4fbO-9d14- 
The key' s randomart image is: 
+---[RSA 2048]- 
96137bcsaa4a 
| 00 
I.E 
S 
o 
o 
Updating project ssh metadata. —tÄdated [https://www.googIeapis.com/compute/vI/projects/qwikIabs—gcp—eOe68b8S7ab09279] . 
Updating project ssh metadata. . .done 
Waiting for SSH key to propagate. 
Warning: Permanently added ' compute. 7133518545770191497' 
Linux gcelab 4.9.o-3-amd64 SMP Debian 4.9.30-2+deb9u3 
(ECDSA) to the list of hosts . 
(2017-08-06) x86 64 
The programs included with the Debi an QIU/Linux system are free software; 
the exact distribution terms for each program are described in the 
individual files in 
Debian GNU/Linux ccmes with NO WARRANTY, to the extent 
permitted by applicable law.

 

이제 gcelab 이라는 VM으로 들어와있는 상태이다.

이 리눅스 VM에 붙어있는 disk device 들이 뭐가 있나 보자

- 맨 아래 녀석이 이번에 붙인 디스크이다. scsi-0Google_PersistentDisk_persistent-disk-1

- 이름은 바꿀 수도 있으며, attach 할때는 --device-name 의 파라미터로 이 이름을 넣어줘야 한다.

goog1e106724 
00 : 46 
00:46 
00 : 59 
00:46 
. . / . ./sdal 
00:46 
00 : 59 
studentegcelab : Is —I /dev/dïsk/by—ïd/ 
total O 
I rwxrwx rwx 
I rwxrwx rwx 
I rwxrwx rwx 
I rwxrwx rwx 
I rwxrwx rwx 
I rwxrwx rwx 
I 
I 
I 
I 
zoo t 
zoo t 
zoo t 
zoo t 
zoo t 
zoo t 
zoo t 
zoo t 
zoo t 
zoo t 
zoo t 
zoo t 
9 
IO 
9 
9 
IO 
9 
OC t 
OC t 
OC t 
OC t 
OC t 
OC t 
18 
18 
18 
18 
18 
18 
• /sda 
google—pers i sten t —di sk—O 
. . / / sdal 
google—pers i sten t —di 
google—pers i sten t —di sk—I 
sosi —OGoogIe PersistentDisk 
scsi—OGoogIe PersistentDisk 
scsi—OGoogIe PersistentDisk 
persi t —disk —O 
pers i stent—di 
pers i stent—di sk—I

 

 

Formatting and mounting the persistent disk

 

디렉토리를 만들고, 해당 디스크를 포맷해준다. 파일시스템은 ext4

- 상세한 명령이나 파라미터는 외우지말고, 이렇게 포맷해줘야 한다는 것만 기억하자.

google 106724 
google 106724 
mke2fs 1.43 .4 (31-Jan-2017) 
Discarding device blocks: done 
sudo mkd_ir /rmt/mydisk 
sudo mkfs . ext4 —F —E lazy itable init=O, lazy journal init=O, discard 
dev k/by—id," s cs i—OGoogIe 
PersistentDisk persistent—disk—I 
Creating filesystem with 52428800 4k blocks and 13107200 inodes 
Filesyscem UUID: 9e7ca6f9-81bO-438S-9fcS-80db1d9f8c26 
Superblock backups stored on blocks : 
32768, 98304, 163840, 229376, 294912, 
4096000, 7962624, 11239424, 20480000, 
Allocating group tables: done 
Wri ting inode tables: done 
Creating ournal (262144 blocks) : done 
Wri ting superblocks and filesystem accounting 
819200, 884736, 
1605632, 
2654208, 
23887872 
informa : 
don e

 

mount

 

sudo mount -o discard,defaults /dev/disk/by-id/scsi-0Google_PersistentDisk_persistent-disk-1 /mnt/mydisk

 

VM restart 시에 자동 mount 하기

 

- VM restart 하면 그때마다 다시 mount 해줘야 한다.

- VM restart 시에 자동으로 remount 하게 하려면 다음과 같이 해주면 된다.

1) /etc/fstab 에서

2) "UUID="로 시작하는 부분에 아래를 추가해주면 된다

/dev/disk/by-id/scsi-0Google_PersistentDisk_persistent-disk-1 /mnt/mydisk ext4 defaults 1 1

 

Local SSDs

 

물리적으로 서버에 attach 되는 것.

- 따라서 퍼포먼스가 엄청 좋다.

- high input/output operation per second (=IOPS)

- persistent disk 보다 very low latenty

Less than 1 ms of latency

upto 680,000 read IOPs and 360,000 write IOPs

 

trade off ?

 

- 언제든지 막 쓸 수는 없을 것이고 (availability)

- 내구성의 한계도 있으며 (durability)

- 늘었다 줄었다도 안된다 (flexibility)

 

따라서, 디스크가 뻑나면 데이터 다 날아감에 주의할 것

 

퀵랩말고 개인적 연습

 

- GSP-003 에서 Cloud Launcher 로 만들어본 Nginx Server VM 에서 해보았다.

 

디스크 만들기

gcloud disks create mydiskl - -size=IøGB - -zone us-centrall-c 
NI%: You have selected a disk size of under [20063]. This may result in poor I/O performance. For more information, 
https://developers.google.com/compute/docs/disks#performance. 
reated . 
see : 
ZONE 
SIZE TYPE 
STATUS 
diskl us-centrall-c Iø 
pd - standard READY 
ew disks are unformatted. You must format and mount a disk before it 
can be used. You can find instructions on how to do this at: 
https://cloud.google.com/compute/docs/disks/add-persistent-disk#formatting

 

*참고. 웹콘솔에서 만들수도 있다

Compute Engine 
VM instances 
Instance groups 
Instance templates 
Snapshots 
Images 
Committed use discounts 
Metadata 
Health checks 
Zones 
Operations 
Quotas 
Settings 
Create a disk 
Name O 
disk-I 
Description (Optionan 
Zone 
us-centralV: 
Disk Type 
Standard persistent disk 
Source type 
Image Snapshot None (blank disk) 
size (GB) O 
Estimated performance 
Operation Type 
Sustained random IOPS limit 
Sustained throughput limit (MB's) 
Encryption 
Automatic (recommended) 
Read 
375.00 
6000 
Write 
750.00 
60 no 
Create 
Cancel

 

왼쪽에서 만든 디스크를 VM에 붙여보기

- 편집 화면에서 선택할 수 있다.

 

시스템 생성 대체 텍스트:
수 VM instance details 
instance-I 
Delete boot disk When instance is deleted 
Additional disks 
口 
0 
回 
[네 
田 
Compute Englne 
VM instances 
Instance 뗜OL니]3 
Instance templates 
대회(s 
Snapshots 
Images 
Committed use discounts 
Metadata 
Health checks 
Zones 
′ EDIT 
RES 
Name 
mydiskl 
Create disk 
Mode 
Read/write 
Read/write 
When deleting instance 
Keep 13k 
Keep disk 
Standard persistent disk, 200 G8, unmo니nted 
mydiskl 
Standard persistent disk, 10138

 

 

 

VM 붙여보기

 

웹콘솔에서도 확인 가능

 

Boot disk and local disks 
Name 
Instance-I 
[S' Oe'ete boot disk when instance is deleted 
Additional disks 
Name 
mydiskl 
size (GB) 
size (GB) 
Type 
Standard persistent disk 
Type 
Standard persistent disk 
Mode 
Boot, read/write 
Mode 
Read/write 
When deleting instance 
Keep disk

 

 

VM 붙어있는 확인

 

Id$ Is 
-al 
otaI 
rwxr -xr - x 
rwxr-xr - x 
I rwxr wx rwx 
I rwxr wx rwx 
I rwxr wx rwx 
I rwxr wx rwx 
I rwxr wx rwx 
I rwxr wx rwx 
2 
root 
6 
root 
I root 
I root 
I root 
I root 
I root 
I root 
root 
root 
root 
root 
root 
root 
root 
root 
16ø 
12ø 
g 
9 
9 
9 
Oct 
Oct 
Oct 
Oct 
Oct 
Oct 
Oct 
Oct 
18 
12 
12 
12 
18 
12 
12 
18 
el : 59 
ø3 : 22 
ø3 : 22 
ø3 : 22 
el : 59 
ø3 : 22 
ø3 : 22 
el : 59 
google- instance-I 
/ . ./sda 
google- instance-I - pa rtI 
google-persistent-disk-I 
scsi-øGoogIe PersistentDisk 
scsi-øGoo le PersistentDisk 
scsi-øGoogIe PersistentDisk 
/. ./sdal 
> ../../sdb 
instance-I 
instance-I- 
persistent-disk-I 
rtI 
/ . ./sda 
/ . ./sdal 
> ../../sdb

 

포맷과 마운팅

포맷: 띄어쓰기 주의할 것

sudo mkfs.ext4 -F -E /dev/disk/by-id/scsi-ø600gIe P 
ersistentoisk_persistent-disk-l 
mke2fs 1.43.4 (31-Jan-2ø17) 
Discarding device blocks: done 
Creating filesystem with 262144ø 4k blocks 
and 65536ø inodes 
Filesystem UUID: 3øa8øe74-25db-4bfc-9b6c-b476b4f3øeøb 
Superblock backups stored on blocks : 
32768, 983ø4, 16384ø, 229376, 294912, 8192øø, 884736, 
16ø5632 
Allocating group tables: done 
Writing inode tables: done 
Creating journal (16384 blocks): done 
Writing superblocks and filesystem accounting information: 
done

 

마운트

 

VM restart 시에 자동 remounting 부분 설정

 

 

 

/etc/fstab 부분을 변경해주면 된다. 이건 귀찮아서 패쓰.

자세한 설명은 링크: https://cloud.google.com/compute/docs/disks/add-persistent-disk#formatting

 

 

Microsoft OneNote 2016에서 작성